{extend name="base/index"/}
{block name="page_location"}
<div class="row">
	<div class="col-12">
		<div class="page-title-box">
			<div class="page-title-right">
				<ol class="breadcrumb m-0">
					<li class="breadcrumb-item"><a href="{:url('index/index')}">管理中心</a></li>
					<li class="breadcrumb-item active"><i class="iconfont icon-angle-right"></i>订单管理</li>
				</ol>
			</div>
			<h4 class="page-title">所有订单</h4>
		</div>
	</div>
</div>
{/block}
{block name="body"}
<link rel="stylesheet" href="__PLUGIN__/jQuery.cxCalendar/css/jquery.cxcalendar.css" />
<div class="row" id="order_page">
	<div class="col-12">
		<div class="card">
			<div class="card-body">
				<form action="{:url('order/index')}" method="get"  id="search_frm">
					<div class="form-row align-items-center">
						<div class="col-auto">
							<label class="sr-only" for="inlineFormInputGroup"></label>
							<div class="input-group mb-2">
								<div class="input-group-prepend">
									<div class="input-group-text">选择状态</div>
								</div>
								<select class="form-control" tabindex="1" name="status">
									<option value="">所有订单</option>
									<option value="1" {eq name="status" value="1"}selected="selected"{/eq}>已下单</option>
									<option value="2" {eq name="status" value="2"}selected="selected"{/eq}>已支付</option>
									<option value="3" {eq name="status" value="3"}selected="selected"{/eq}>已发货</option>
									<option value="4" {eq name="status" value="4"}selected="selected"{/eq}>已收货</option>
									<option value="5" {eq name="status" value="5"}selected="selected"{/eq}>已评价</option>
								</select>
							</div>								
						</div>	
						<div class="col-auto">
							<label class="sr-only" for="inlineFormInputGroup"></label>
							<div class="input-group mb-2">
								<div class="input-group-prepend">
									<div class="input-group-text">开始</div>
								</div>
								<input type="text" class="form-control" name="stime" placeholder="选择开始时间" value="{$stime}">
							</div>
						</div>
						<div class="col-auto">
							<label class="sr-only" for="inlineFormInputGroup"></label>
							<div class="input-group mb-2">
								<div class="input-group-prepend">
									<div class="input-group-text">结束</div>
								</div>
								<input type="text" class="form-control" name="etime" placeholder="选择开始时间" value="{$etime}">
							</div>
						</div>
						<div class="col-auto">
							<label class="sr-only" for="inlineFormInputGroup"></label>
							<div class="input-group mb-2">
								<div class="input-group-prepend">
									<div class="input-group-text">搜索</div>
								</div>
								<input type="text" class="form-control kw enter_goto" name="kw" placeholder="搜索会员名、订单号、收货人、电话" value="{$kw}">
							</div>
						</div>
						<div class="col-auto">
							<button type="submit" class="btn btn-primary mb-2">搜索</button>
						</div>
						<div class="col-auto">
							<label class="sr-only" for="inlineFormInputGroup"></label>
							<div class="input-group mb-2">
								<div class="input-group-addon">
									<button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true"
									 aria-expanded="false">更多操作</button>
									<div class="dropdown-menu" x-placement="bottom-start" style="position: absolute; will-change: transform; top: 0px; left: 0px; transform: translate3d(0px, 37px, 0px);">
										<a href="javascript:;" class="dropdown-item check_select_btn" id="export_xls_btn">结果导出</a>
										<a href="javascript:;" class="dropdown-item check_select_btn" id="batch_send_btn" data-toggle="modal" data-target="#order_bat_send_box">批量发货</a>
									</div>
								</div>
							</div>
						</div>
					</div>
				</form>
                <table class="table table-hover">
                    <thead>
                        <tr>
                            <th>订单编号</th>
                            <th>会员名称</th>
                            <th>会员昵称</th>
                            <th>总金额</th>
                            <th>实际支付</th>
                            <th>订单状态</th>
                            <th>下单时间</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        {volist name='list' id="data"}
                        <tr>
                            <td>{$data.oid}</td>
                            <td><a href="{:url('member/index')}?classid=0&kw={$data.uname}" target="_blank">{$data.uname|ReStrLen=10}</a></td>
							<td>{$data.nickname}</td>
                            <td>{$data.amount} 元</td>
                            <td>{$data.pay_amount} 元</td>
                            <td>
                            	{switch name="data.status"}
                            		{case value="1"}<span class="badge badge-secondary">已下单,待支付</span>{/case}
                            		{case value="2"}<span class="badge badge-primary">已支付,待发货</span>{/case}
                            		{case value="3"}<span class="badge badge-danger">已发货,待收货</span>{/case}
                            		{case value="4"}<span class="badge badge-success">已收货</span>{/case}
                            		{case value="5"}<span class="badge badge-secondary">已评价</span>{/case}
                            	{/switch}
                            </td>
                            <td title="{$data.posttime|date="Y-m-d H:i:s",###}"><span class="badge badge-primary">{$data.posttime|date="m-d H:i",###}</span></td>
                            <td>
                            	<a href="javascript:;" class="btn btn-primary btn-sm more_btn" attr-id="{$data.id}">订单详情</a>
								<div class="btn-group">
									<button type="button" class="btn btn-primary btn-sm dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">操作</button>
									<div class="dropdown-menu">
										<a href="javascript:;" class="dropdown-item order_send_btn" attr-id="{$data.id}" data-toggle="modal" data-target="#order_send_box">订单发货</a>
										<a href="javascript:;" class="dropdown-item set_amount_btn" attr-id="{$data.id}" data-toggle="modal" data-target="#order_amount_box">修改订单总价</a>
										<div class="dropdown-divider"></div>
										<a href="javascript:;" class="dropdown-item Fast_Del" attr-id="{$data.id}" attr-model="order">删除</a>
									</div>
								</div>
                            </td>
                        </tr>
                        <tr id="goods_{$data.id}" class="goods_more" style="display: none;">
                        	<td colspan="8">
								<div class="card">
									<div class="card-header">订单：{$data.oid} 产品列表</div>
									<div class="card-body">
										<table class="table table-centered mb-0" >
											<tr>
												<th>产品图片</th>
												<th>产品名称</th>
												<th>产品数量</th>
												<th>产品单价</th>
												<th>产品运费</th>
												<th>产品总价</th>
											</tr>
											{volist name="data.glist" id="g"}
											<tr>
												<td><img src="{$g.gpicurl|default='/static/admin/images/nopic.png'}" width="50" height="50" alt="" /></td>
												<td>{$g.gname}</td>
												<td>{$g.num} 件</td>
												<td>{$g.buyprice} 元</td>
												<td>{$g.packing} 元</td>
												<td>{$g.amount} 元</td>
											</tr>
											{/volist}
										</table>
									</div> <!-- end card-body-->
								</div>
								<div class="card">
									<div class="card-header">订单：{$data.oid} 收件人信息</div>
									<div class="card-body">
										<table class="table table-sm table-centered mb-0">
											<tr>
												<th style="width: 10%;">收货人：</th>
												<td style="width: 20%;">{$data.consignee_name}</td>
												<th style="width: 10%;">收货手机：</th>
												<td style="width: 20%;">{$data.consignee_mobile}</td>
												<th style="width: 10%;">收货地址：</th>
												<td style="width: 30%;">{$data.consignee_address}</td>
											</tr>
											<tr>
												<th style="width: 10%;">买家备注：</th>
												<td colspan="5">{$data.buyremark}</td>
											</tr>	
											<tr>
												<th style="width: 10%;">支付时间：</th>
												<td style="width: 20%;">{$data.paytime|MyDate='Y-m-d H:i:s',###}</td>
												<th style="width: 10%;">发货时间：</th>
												<td style="width: 20%;">{$data.sendtime|MyDate='Y-m-d H:i:s',###}</td>
												<th style="width: 10%;">收货时间：</th>
												<td style="width: 30%;">{$data.retime|MyDate='Y-m-d H:i:s',###}</td>
											</tr>											
										</table>
									</div> <!-- end card-body-->
								</div>
								
								{egt name="data.status" value="3"}
								<div class="card">
									<div class="card-header">订单：{$data.oid} 收件人信息</div>
									<div class="card-body">
										<table class="table table-sm table-centered mb-0">
											<tr>
												<th style="width: 20%;">物流公司：</th>
												<td style="width: 30%;">{$data.express_name}</td>
												<th style="width: 20%;">物流单号：</th>
												<td style="width: 30%;">{$data.express_id}</td>
											</tr>
										</table>
									</div> <!-- end card-body-->
								</div>
								{/egt}
                        	</td>
                        </tr>
                        {/volist}
                    </tbody>
                </table>
				<div class="row">
					<div class="col-12" style="text-align: center;">
						{$pagelist}
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
{/block}
{block name="modal_dig"}
<div class="modal fade" id="order_send_box" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h4 class="modal-title dig_title" id="myModalLabel">订单发货</h4>
		<button type="button" class="close" data-dismiss="modal">x</button>
      </div>
      <div class="modal-body">
            <form action="#" class="form-horizontal" id="order_send_frm">
            	<input type="hidden" name="id" value="" />
                <div class="form-group row mb-1">
                    <label class="col-3 col-form-label">物流公司：</label>
                    <div class="col-5">
						<input type="text" name="express_name" class="form-control" value="">
                    </div>
                </div> 				
                <div class="form-group row mb-1">
                    <label class="col-3 col-form-label">运单号：</label>
                    <div class="col-5">
                        <input type="text" name="express_id" class="form-control" value="">
                    </div>
                </div>
				<div class="form-group row mb-1">
                    <label class="col-3 col-form-label">联系电话：</label>
                    <div class="col-5">
                        <input type="text" name="express_tel" class="form-control" value="">
                    </div>
                </div>
                <div class="form-group row mb-1">
                    <label class="col-3 col-form-label">重量：</label>
                    <div class="col-5">
                        <input type="text" name="express_weight" class="form-control" value="">
                    </div>
                </div>  				
            </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
        <button type="button" class="btn btn-primary" id="save_order_send_btn">立即发货</button>
      </div>
    </div>
  </div>
</div>

<div class="modal fade" id="order_amount_box" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h4 class="modal-title dig_title" id="myModalLabel">订单总价修改</h4>
		<button type="button" class="close" data-dismiss="modal">x</button>
      </div>
      <div class="modal-body">
            <form action="#" class="form-horizontal" id="order_amount_frm">
            	<input type="hidden" name="id" value="" />		
                <div class="form-group row mb-1">
                    <label class="col-3 col-form-label">订单总价：</label>
                    <div class="col-5">
                        <input type="text" name="amount" class="form-control" value="">
                    </div>
                </div>          
            </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
        <button type="button" class="btn btn-primary" id="save_order_amount_btn">立即修改</button>
      </div>
    </div>
  </div>
</div>

<div class="modal fade" id="order_bat_send_box" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog" style="max-width: 1000px;">
    <div class="modal-content">
      <div class="modal-header">
        <h4 class="modal-title dig_title" id="myModalLabel">订单批量发货</h4>
		<button type="button" class="close" data-dismiss="modal">x</button>
      </div>
      <div class="modal-body" style="max-height: 500px!important;background-color: #FFF;overflow: auto;">
            <form action="#" class="form-horizontal" id="order_bat_send_frm">
            	<input type="hidden" name="id" value="" />		
                <div class="form-group row mb-1">
                    <label class="col-3 col-form-label">上传xls：</label>
                    <div class="col-5">
                        <div class="config_uploadfile xlsfile form_input_check" data-type="upload" attr-inputname="xlsfile" nullmsg="Excel文件没有上传" attr-value=""></div>
                    </div>
                    <button type="button" class="btn btn-primary" id="save_order_bat_send_btn">表格导入</button>
                </div>
            </form>
            <form action="" method="post">
				<table class="table table-hover">
	                <thead>
	                    <tr>
	                        <th>订单编号</th>
	                        <th>昵称</th>
	                        <th>运费</th>
	                        <th>总价</th>
	                        <th>收货人</th>
	                        <th>收货手机</th>
	                        <th>收货地址</th>
	                        <th>物流公司</th>
	                        <th>物流单号</th>
	                        <th>状态</th>
	                        <th>发货结果</th>
	                    </tr>
	                </thead>
	                <tbody id="order_batsend_data_list">
						
	                </tbody>
	            </table>
            </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
        <button type="button" class="btn btn-primary" id="order_bat_send_btn">立即发货</button>
      </div>
    </div>
  </div>
</div>
{/block}
{block name="script"}
<script type="text/javascript" src="__PLUGIN__/jQuery.cxCalendar/js/jquery.cxcalendar.min.js"></script>
<script type="text/javascript" src="__PLUGIN__/jQuery.cxCalendar/js/jquery.cxcalendar.languages.js"></script>
<script type="text/javascript">
$(function(){
	$("input[name=stime]").cxCalendar({type: 'datetime',format: 'YYYY-MM-DD HH:mm:ss'});
	$("input[name=etime]").cxCalendar({type: 'datetime',format: 'YYYY-MM-DD HH:mm:ss'});
});
</script>
{/block}